package com.aptech.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.aptech.bean.Users;

public class UserDao {

	public boolean isCorrectUser(Users user) {
		Session session = HibernateUtil.currentSession();
		Query query = session.getNamedQuery("select");
		List<Users> users = query.list();
		for (Users u : users) {
			if (user.getUserName().equals(u.getUserName()) 
					&& user.getPassword().equals(u.getPassword())) {
				return true;
			}
		}
		return false;
	}
	
	public Users getCorrectUser(Users user) {
		Session session = HibernateUtil.currentSession();
		Query query = session.getNamedQuery("select");
		List<Users> users = query.list();
		for (Users u : users) {
			if (user.getUserName().equals(u.getUserName()) 
					&& user.getPassword().equals(u.getPassword())) {
				return u;
			}
		}
		return null;
	}
}
